package com.yunhe.authority.controller.feign;

import com.yunhe.authority.domain.authority.Project;
import com.yunhe.authority.domain.authority.ProjectData;
import com.yunhe.authority.domain.authority.Station;
import com.yunhe.authority.service.authority.StationForTransferService;
import com.yunhe.authority.service.authority.StationService;
import com.yunhe.common.annotation.OperationRecord;
import com.yunhe.common.constant.SystemConsts;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import com.yunhe.common.model.ResultObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * 电站Controller
 * @author liuronglei
 */
@RestController
@RequestMapping("/stationForTransfer")
public class StationForDataTransferController {

    @Autowired
    private StationService stationService;

    @Autowired
    private StationForTransferService stationForTransferService;

    /**
     * 获取园区列表
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getStations", method = RequestMethod.GET)
    public ResultObject<List<Station>> getStations(@RequestParam(value = "userId",required = false) Long userId) {
        List<Station> stations = stationForTransferService.getStations(userId);
        return new ResultObject<>(stations);
    }

    /**
     * 根据园区ID获得园区
     * @param stationId 园区ID
     */
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public ResultObject<Station> getStationById(@PathVariable("id") Long stationId) {
        Station station = stationService.findById(stationId);
        return new ResultObject<>(station);
    }

    /**
     * 根据园区code获得园区
     * @param
     */
    @RequestMapping(value = "/byCode", method = RequestMethod.GET)
    public ResponseEntity<ResultObject<Station>> getStationByCode(@RequestParam(value = "code") Long code) {
        Station station = stationService.findByCode(code);
        return new ResponseEntity<>(new ResultObject<>(station), HttpStatus.OK);
    }


}
